import subprocess

subprocess.run(["xvlog","--sv","my_adder.sv"])
subprocess.run(["xvlog","--sv","testbench_with_sb.sv"])
subprocess.run(["xelab","-debug" ,"all" ,"--snapshot" ,"sp1" ,"testbench_with_sb"])
xsim_process = subprocess.Popen(["xsim", "sp1"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)

xsim_process.stdin.write("open_vcd\n")
xsim_process.stdin.write("log_vcd *\n")
xsim_process.stdin.write("run 100ns\n")
xsim_process.stdin.write("close_vcd\n")
xsim_process.stdin.write("quit\n")

xsim_process.stdin.flush()
xsim_process.communicate() 
# subprocess.run(["xsim" ,"sp1","-tclbatch" ,"test.tcl"])


# xelab -debug all --snapshot snapshot_name tb_my_module -cc test.cc


#  make clean
#  make compile 
#  xvlog --sv my_adder.sv
#  xvlog --sv testbench_with_sb.sv 
#  xelab -debug all --snapshot sp1 testbench_with_sb
#  xsim sp1